package com.niit.onlinemusicserver34.common;

import lombok.Data;

@Data
public class Result<T> {

    private int code; // 1001 登录成功  1002 登录失败 2001 转账成功  2002 转账失败

    private boolean status = true; // true 请求成功  false 请求失败

    private String message;

    private T data;

    public static <T> Result success(T data){
        Result<T> result = new Result<>();
        result.code=200;
        result.message="请求成功";
        result.setData(data);
        return result;
    }

    public static <T> Result fail(T data){
        Result<T> result = new Result<>();
        result.code=201;
        result.message="请求失败";
        result.setData(data);
        result.setStatus(false);
        return result;
    }
}
